package com.goodving.guli.view;

import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.activity.SearchWeightScaleActivity;
import com.goodving.guli.activity.ff;
import com.goodving.guli.activity.fh;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.lua.SlidingUpPanelLayout;
import com.goodving.guli.bt.profile.scale.GuliLog;

/**
 * Created by john on 2015/11/24.
 */
public class ScaleBindFragment extends XMBaseFragment implements View.OnClickListener { //C1797B
    private static final String f8790b = "BindDevicesWeightFragment";
    private static final int f8791c = 256;
    private SlidingUpPanelLayout f8792d;

    private void m13591d() {
        fh a = new ff(getActivity()).m14851a();
        if (a.m14878d()) {
            int e = a.m14879e();
            int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.main_ui_panel_height);
            GuliLog.tracePrintInfo(f8790b, "SlidingPanel SystemBarH : " + e + ", OriginalPanelH : " + dimensionPixelSize);
            this.f8792d.setPanelHeight(dimensionPixelSize - e);
        }
    }

    public void m13592c() {
        GuliLog.tracePrintInfo(f8790b, "On start bind clicked!!");
        startActivityForResult(new Intent(getActivity(), SearchWeightScaleActivity.class), f8791c);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        GuliLog.tracePrintInfo(f8790b, "onActivityResult requestCode = " + i + ", resultCode " + i2);
        if (i == f8791c && i2 == -1 && getActivity() != null) {
            getActivity().finish();
        }
        super.onActivityResult(i, i2, intent);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.about_mi_band:
                C0668a.m8126a(getActivity().getApplicationContext(), C0668a.gp);
//                Utils.m8010a("http://s1.mi.com/m/product/scale/", (int) R.string.bracelet_store_desc, getActivity());
            case R.id.start_bind:
                m13592c();
            default:
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.activity_bind_device_weight, viewGroup, false);
        ((TextView) inflate.findViewById(R.id.about_mi_band)).setText(Html.fromHtml(getString(R.string.bind_mi_weight_about)));

        inflate.findViewById(R.id.about_mi_band).setOnClickListener(this);
        inflate.findViewById(R.id.start_bind).setOnClickListener(this);
        this.f8792d = (SlidingUpPanelLayout) inflate.findViewById(R.id.fragment_setting_sliding_layout);
        this.f8792d.setSlidingEnabled(false);
        m13591d();
        return inflate;
    }
}
